package ahblue.cn.tanzi.ui.person;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import ahblue.cn.tanzi.R;
import ahblue.cn.tanzi.jmessage.im.util.ToastUtil;
import ahblue.cn.tanzi.model.user.CodeModel;
import ahblue.cn.tanzi.model.user.LoginResultModel;
import ahblue.cn.tanzi.ui.base.BaseActivity;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by fengdongfei on 2018/12/1.
 */

public class RealActivity extends BaseActivity {
    @BindView(R.id.etname)
    EditText etname;
    @BindView(R.id.etsfz)
    EditText etsfz;
    @BindView(R.id.etcard)
    EditText etcard;
    @BindView(R.id.realname)
    EditText realname;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_real);
        ButterKnife.bind(this);


    }

    @OnClick({R.id.btn_back, R.id.tvok})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_back:
                finish();
                break;
            case R.id.tvok:
                String realnameS=realname.getText().toString();
                if (TextUtils.isEmpty(realnameS)){
                    ToastUtil.shortToast(this,"请输入您的姓名");
                    return;
                }
                String bankCard=etcard.getText().toString();
                if (TextUtils.isEmpty(bankCard)){
                    ToastUtil.shortToast(this,"请输入银行卡号");
                    return;
                }

                String Name=etname.getText().toString();
                if (TextUtils.isEmpty(Name)){
                    ToastUtil.shortToast(this,"请输入支付宝账号");
                    return;
                }

                String identF=etsfz.getText().toString();
                if (TextUtils.isEmpty(identF)){
                    ToastUtil.shortToast(this,"请输入身份证号");
                    return;
                }

                CodeModel.inviteRealCode(this, LoginResultModel.getToken(this),
                        bankCard, Name, identF,realnameS, new CodeModel.VertifyListener() {
                            @Override
                            public void conver(boolean b) {
                                if (b){
                                    setResult(1001);
                                    finish();
                                }else {
                                }
                            }
                        });
                break;
        }
    }
}
